#include <QFile>
#include <QDir>
#include <QDateTime>
#include "logdt.h"

#define LOGDT_FILE_PATH "../../log/log.txt"

Logdt::Logdt() {}

int Logdt::LogdtInput(QString content)
{
    QFile *file = new QFile(LOGDT_FILE_PATH);//此路径下没有就会自己创建一个

    if (file->open(QIODevice::ReadWrite | QIODevice::Append) == false)//以读写切追加写入的方式操作文本
    {
        return -1;
    }

    QTextStream txtOutput(file);
    txtOutput << "[" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") << "]\t" << content << Qt::endl;
    file->close();

    return 0;
}
